package com.ewanghuiju.app.ui.my.adapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ewanghuiju.app.R;
import com.ewanghuiju.app.model.bean.response.BillListResponBean;

import androidx.core.content.ContextCompat;

/**
 * @author sj  qq:751943509
 * @class 钱包流水账单 adapter
 * @time 2020/2/20
 */
public class WalletBillListAdapter extends BaseQuickAdapter<BillListResponBean, BaseViewHolder> {
    private int mType;

    public WalletBillListAdapter(int layoutResId, int type) {
        super(layoutResId);
        this.mType = type;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    protected void convert(BaseViewHolder helper, BillListResponBean item) {
        helper.setText(R.id.tv_intro, TextUtils.isEmpty(item.getRemake()) ? "" : item.getRemake());
        TextView tvAmount = helper.getView(R.id.tv_amount);
        if (mType == 1) {
            //收入
            tvAmount.setTextColor(ContextCompat.getColor(mContext, R.color.colorPrimary));
        } else {
            //支出
            tvAmount.setTextColor(ContextCompat.getColor(mContext, R.color.color_333));
            TextView tvInfo = helper.getView(R.id.tv_info);
            if(TextUtils.isEmpty(item.getInfo())){
                tvInfo.setVisibility(View.GONE);
            }else{
                tvInfo.setVisibility(View.VISIBLE);
                tvInfo.setText(item.getInfo());
            }
        }
        tvAmount.setText(TextUtils.isEmpty(item.getPrice()) ? "" : item.getPrice());
        helper.setText(R.id.tv_date, TextUtils.isEmpty(item.getCreate_time()) ? "" : item.getCreate_time());
//        ImageView iv = helper.getView(R.id.iv_head);
//        switch (item.getCheck()) {
//            case 1:
//            case 2:
//                iv.setImageResource(R.mipmap.icon_pin);
//                break;
//            case 3:
//                iv.setImageResource(R.mipmap.icon_pin);
//                break;
//            case 4:
//                iv.setImageResource(R.mipmap.icon_chong);
//                break;
//            case 5:
//                iv.setImageResource(R.mipmap.icon_ti);
//                break;
//            default:
//                break;
//        }
    }
}
